package rullekake.entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Studieprogramklasse.
 * Holder på alle data og relasjonsinformasjon for studieprogramm. Består av set/get for alt + equals, hashcode og toString.
 *
 */
@Entity
@Table(name = "STUDY_PROGRAM")
@NamedQueries({
    @NamedQuery(name = "StudyProgram.findAll", query = "SELECT s FROM StudyProgram s"),
    @NamedQuery(name = "StudyProgram.findByStudyProgramId", query = "SELECT s FROM StudyProgram s WHERE s.studyProgramId = :studyProgramId"),
    @NamedQuery(name = "StudyProgram.findByStudyProgramName", query = "SELECT s FROM StudyProgram s WHERE s.studyProgramName = :studyProgramName"),
    @NamedQuery(name = "StudyProgram.findByStudyProgramNameNo", query = "SELECT s FROM StudyProgram s WHERE s.studyProgramNameNo = :studyProgramNameNo"),
    @NamedQuery(name = "StudyProgram.findByApproved", query = "SELECT s FROM StudyProgram s WHERE s.approved = :approved"),
    @NamedQuery(name = "StudyProgram.findByApprovedBy", query = "SELECT s FROM StudyProgram s WHERE s.approvedBy = :approvedBy"),
    @NamedQuery(name = "StudyProgram.findByRevised", query = "SELECT s FROM StudyProgram s WHERE s.revised = :revised"),
    @NamedQuery(name = "StudyProgram.findByRevisedBy", query = "SELECT s FROM StudyProgram s WHERE s.revisedBy = :revisedBy"),
    @NamedQuery(name = "StudyProgram.findByNationalFramework", query = "SELECT s FROM StudyProgram s WHERE s.nationalFramework = :nationalFramework"),
    @NamedQuery(name = "StudyProgram.findByFaculty", query = "SELECT s FROM StudyProgram s WHERE s.faculty = :faculty")})
public class StudyProgram implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "STUDY_PROGRAM_ID")
    private Integer studyProgramId;
    @Basic(optional = false)
    @Column(name = "STUDY_PROGRAM_NAME")
    private String studyProgramName;
    @Basic(optional = false)
    @Column(name = "STUDY_PROGRAM_NAME_NO")
    private String studyProgramNameNo;
    @Column(name = "APPROVED")
    @Temporal(TemporalType.DATE)
    private Date approved;
    @Column(name = "APPROVED_BY")
    private String approvedBy;
    @Column(name = "REVISED")
    @Temporal(TemporalType.DATE)
    private Date revised;
    @Column(name = "REVISED_BY")
    private String revisedBy;
    @Column(name = "NATIONAL_FRAMEWORK")
    private String nationalFramework;
    @ManyToMany(mappedBy = "studyProgramCollection")
    private Collection<Course> courseCollection;
    @JoinColumn(name = "FACULTY_ID", referencedColumnName = "FACULTY_ID")
    @ManyToOne(optional = false)
    private Faculty faculty;

    public StudyProgram() {
    }

    public StudyProgram(Integer studyProgramId) {
        this.studyProgramId = studyProgramId;
    }

    public StudyProgram(Integer studyProgramId, String studyProgramName, String studyProgramNameNo) {
        this.studyProgramId = studyProgramId;
        this.studyProgramName = studyProgramName;
        this.studyProgramNameNo = studyProgramNameNo;
    }

    public Integer getStudyProgramId() {
        return studyProgramId;
    }

    public void setStudyProgramId(Integer studyProgramId) {
        this.studyProgramId = studyProgramId;
    }

    public String getStudyProgramName() {
        return studyProgramName;
    }

    public void setStudyProgramName(String studyProgramName) {
        this.studyProgramName = studyProgramName;
    }

    public String getStudyProgramNameNo() {
        return studyProgramNameNo;
    }

    public void setStudyProgramNameNo(String studyProgramNameNo) {
        this.studyProgramNameNo = studyProgramNameNo;
    }

    public Date getApproved() {
        return approved;
    }

    public void setApproved(Date approved) {
        this.approved = approved;
    }

    public String getApprovedBy() {
        return approvedBy;
    }

    public void setApprovedBy(String approvedBy) {
        this.approvedBy = approvedBy;
    }

    public Date getRevised() {
        return revised;
    }

    public void setRevised(Date revised) {
        this.revised = revised;
    }

    public String getRevisedBy() {
        return revisedBy;
    }

    public void setRevisedBy(String revisedBy) {
        this.revisedBy = revisedBy;
    }

    public String getNationalFramework() {
        return nationalFramework;
    }

    public void setNationalFramework(String nationalFramework) {
        this.nationalFramework = nationalFramework;
    }

    public Collection<Course> getCourseCollection() {
        return courseCollection;
    }

    public void setCourseCollection(Collection<Course> courseCollection) {
        this.courseCollection = courseCollection;
    }

    public Faculty getFaculty() {
        return faculty;
    }

    public void setFaculty(Faculty faculty) {
        this.faculty = faculty;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (studyProgramId != null ? studyProgramId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof StudyProgram)) {
            return false;
        }
        StudyProgram other = (StudyProgram) object;
        if ((this.studyProgramId == null && other.studyProgramId != null) || (this.studyProgramId != null && !this.studyProgramId.equals(other.studyProgramId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "rullekake.entities.StudyProgram[studyProgramId=" + studyProgramId + "]";
    }

}
